<template>
  <BasicModal v-bind="$attrs" @register="registerModal"     :footer="null" width="60%"
              minHeight="120"
              destroyOnClose>
    <a-list :grid="{ gutter: 16, xs: 1, sm: 2, md: 4, lg: 4, xl: 6, xxl: 3 }" :data-source="dataInfo">
      <template #renderItem="{ item }">
        <a-list-item>
          <a-card :title="item.title">
            <Description :column="1" :data="item"  :bordered="false"   :schema="formSchema" >
            </Description>
          </a-card>
        </a-list-item>
      </template>
    </a-list>

  </BasicModal>
</template>
<script lang="ts" setup>
import { ref, useAttrs } from 'vue';
import { Description, useDescription } from '/@/components/Description/index';
import BasicModal from "/@/components/Modal/src/BasicModal.vue";
import {useModalInner} from "/@/components/Modal";
const emit = defineEmits(['register']);
const attrs = useAttrs();
// 计划数据
const dataInfo = ref([]);
// 表单结构
const formSchema =  [

  {
    label: '产品',
    field: 'productNo_dictText',
  },
  {
    label: '地块',
    field: 'plotId_dictText',
  },

  {
    label: '计划时间',
    field: 'planTime',
    render: (planTime, record) => {
      let content = '';
      if (record.startTime) {
        content += record.startTime.length > 10 ? record.startTime.substr(0,10) : record.startTime;
        content += " → ";
      }
      if (record.stopTime) {
        content += record.stopTime.length > 10 ? record.stopTime.substr(0,10) : record.stopTime;
      }
      return content;
    },
  },
  {
    label: '实际时间',
    field: 'planTime',
    render: (planTime, record) => {
      let content = '';
      if (record.actualStartTime) {
        content += record.actualStartTime.length > 10 ? record.actualStartTime.substr(0,10) : record.actualStartTime;
        content += " → ";
      }
      if (record.actualStopTime) {
        content += record.actualStopTime.length > 10 ? record.actualStopTime.substr(0,10) : record.actualStopTime;
      }
      return content;
    },
  },
  {
    label: '计划编号',
    field: 'planId'
  },

];
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  setModalProps({ confirmLoading: false,title:data.plot.name });
  dataInfo.value = data.datas;
  console.log(dataInfo.value);
});
</script>
